﻿@model List<DataModel.Test.TestResult>
@{
    
    Layout = null;
}

<!DOCTYPE html>
<html>
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>@ViewBag.TestName</title>
        <link href="../../Content/style.css" rel="stylesheet" />
        <script src="../../Scripts/amcharts/amcharts.js"></script>
        <script src="../../Scripts/harlem-shake-script.js"></script>
        <script type="text/javascript">
            var chart;

            var chartData = [{
                count: 2005,
                mongo: 23.5,
                sql: 18.1
            }, {
                count: 2006,
                mongo: 26.2,
                sql: 22.8
            }, {
                count: 2007,
                mongo: 30.1,
                sql: 23.9
            }, {
                count: 2008,
                mongo: 29.5,
                sql: 25.1
            }, {
                count: 2009,
                mongo: 24.6,
                sql: 25.0
            }];


            chartData = @(Html.Raw(Json.Encode(Model)));


            AmCharts.ready(function () {
                // SERIAL CHART
                chart = new AmCharts.AmSerialChart();
                chart.dataProvider = chartData;
                chart.categoryField = "count";
                chart.startDuration = 1;
                chart.plotAreaBorderColor = "#DADADA";
                chart.plotAreaBorderAlpha = 1;
                // this single line makes the chart a bar chart          
                chart.rotate = true;

                // AXES
                // Category
                var categoryAxis = chart.categoryAxis;
                categoryAxis.gridPosition = "start";
                categoryAxis.gridAlpha = 0.1;
                categoryAxis.axisAlpha = 0;

                // Value
                var valueAxis = new AmCharts.ValueAxis();
                valueAxis.axisAlpha = 0;
                valueAxis.gridAlpha = 0.1;
                valueAxis.position = "top";
                chart.addValueAxis(valueAxis);

                // GRAPHS
                // first graph
                var graph1 = new AmCharts.AmGraph();
                graph1.type = "column";
                graph1.title = "Sql";
                graph1.valueField = "sql";
                graph1.balloonText = "sql:[[value]]";
                graph1.lineAlpha = 0;
                graph1.fillColors = "#ADD981";
                graph1.fillAlphas = 1;
                chart.addGraph(graph1);

                // second graph
                var graph2 = new AmCharts.AmGraph();
                graph2.type = "column";
                graph2.title = "Mongo";
                graph2.valueField = "mongo";
                graph2.balloonText = "Mongo:[[value]]";
                graph2.lineAlpha = 0;
                graph2.fillColors = "#81acd9";
                graph2.fillAlphas = 1;
                chart.addGraph(graph2);

                // LEGEND
                var legend = new AmCharts.AmLegend();
                chart.addLegend(legend);

                // WRITE
                chart.write("chartdiv");
            });
        </script>
    </head>
    <h1>@ViewBag.TestName</h1>
    <body>
        <div id="chartdiv" style="width: 100%; height: 600px;"></div>
    </body>

</html>